package com.backend.modules.system.entity;

import com.backend.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;

@Data
@Entity
@Table(name = "sys_teacher_class")
@EqualsAndHashCode(callSuper = true)
@SQLDelete(sql = "UPDATE sys_teacher_class SET deleted = true WHERE id = ?")
@Where(clause = "deleted = false")
public class SysTeacherClass extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "teacher_id",foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    private SysUser teacher;
    
    @Column(name = "teacher_id", insertable = false, updatable = false)
    private Long teacherId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "class_id",foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    private SysDepartment clazz;
    
    @Column(name = "class_id", insertable = false, updatable = false)
    private Long classId;
} 